package com.zelin.manager.service.impl;

import com.zelin.common.utils.PageUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zelin.common.utils.Query;
import com.zelin.manager.dao.GoodsDao;
import com.zelin.manager.entity.GoodsEntity;
import com.zelin.manager.service.GoodsService;


@Service("goodsService")
public class GoodsServiceImpl extends ServiceImpl<GoodsDao, GoodsEntity> implements GoodsService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        //包装条件查询
        QueryWrapper<GoodsEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("audit_status","0");
        IPage<GoodsEntity> page = this.page(
                new Query<GoodsEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

    /**
     * 功能描述:商品审核
     * 返回值:
     * 作者:LZB
     * 时间: 2021/11/3 8:48
     */
    @Override
    public void updateStatus(Long id, String status) {
        //根据商品id查询商品信息
        GoodsEntity goodsEntity = baseMapper.selectById(id);
        //根据商品信息给商品做修改
        goodsEntity.setAuditStatus(status);
        //修改商品
        baseMapper.updateById(goodsEntity);
    }

}